<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : listProductPDF.xsl
    Created on : May 7, 2013, 1:12 PM
    Author     : NganNLK60334
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:p="http://xml.netbeans.org/schema/products"
                version="1.0">
    <xsl:output method="xml"/>

    <!-- TODO customize transformation rules
         syntax recommendation http://www.w3.org/TR/xslt
-->
    <xsl:template match="/">
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
            <fo:layout-master-set>
                <fo:simple-page-master master-name="Funny-portrait"
                        page-height="29.7cm" page-width="21.0cm" margin="2cm">
                    <fo:region-body/>
                </fo:simple-page-master>
            </fo:layout-master-set>

            <fo:page-sequence master-reference="Funny-portrait">
                <fo:flow flow-name="xsl-region-body">
                    <fo:block font-size="20pt" line-height="50pt" text-align="center" color="red" font-family="Arial">
                        List of Products need to be imported into inventory
                    </fo:block>

                    <fo:block>
                        <fo:table text-align="left">
                            <fo:table-column column-width="15mm"/>
                            <fo:table-column column-width="55mm"/>
                            <fo:table-column column-width="30mm"/>
                            <fo:table-column column-width="20mm"/>
                            <fo:table-column column-width="55mm"/>

                            <fo:table-body>
                                <fo:table-row>
                                    <fo:table-cell border-style="solid" color="blue">
                                        <fo:block>Product ID</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-style="solid" color="blue">
                                        <fo:block>Product Image</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-style="solid" color="blue">
                                        <fo:block>Product Name</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-style="solid" color="blue">
                                        <fo:block>Quantity InStock</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-style="solid" color="blue">
                                        <fo:block>Description</fo:block>
                                    </fo:table-cell>
                                </fo:table-row>

                                <xsl:for-each select="p:products/p:product[p:quantityInStock &lt;= 3]">
                                    <fo:table-row>
                                        <fo:table-cell border-style="solid">
                                            <fo:block font-family="Arial">
                                                <xsl:value-of select="p:productID"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border-style="solid" >
                                            <fo:block>
                                                <fo:external-graphic content-height="scale-to-fit" height="2.00in"  content-width="2.00in" src="url(http://localhost:8080/XMLProject/Pictures/{p:productImg})"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border-style="solid">
                                            <fo:block font-family="Arial">
                                                <xsl:value-of select="p:productName"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border-style="solid">
                                            <fo:block font-family="Arial">
                                                <xsl:value-of select="p:quantityInStock"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border-style="solid">
                                            <fo:block font-family="Arial">
                                                <xsl:value-of select="p:description"/>
                                            </fo:block>
                                        </fo:table-cell>
                                    </fo:table-row>
                                </xsl:for-each>
                            </fo:table-body>
                        </fo:table>
                    </fo:block>
                </fo:flow>
            </fo:page-sequence>
        </fo:root>
    </xsl:template>

</xsl:stylesheet>
  
<!--    <xsl:template match="/">
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
            <fo:layout-master-set>
                <fo:simple-page-master master-name="first"
                                       page-height="29.7cm"
                                       page-width="21cm"
                                       margin-top="1cm"
                                       margin-bottom="2cm"
                                       margin-left="2.5cm"
                                       margin-right="2.5cm">
                    <fo:region-body margin-top="3cm"/>
                    <fo:region-before extent="3cm"/>
                    <fo:region-after extent="1.5cm"/>
                </fo:simple-page-master>
            </fo:layout-master-set>

            <fo:page-sequence master-reference="first">
                <fo:flow flow-name="xsl-region-body">
                    <fo:block font-size="20pt"
                              font-family="Arial"
                              line-height="24pt"
                              background-color="cyan"
                              space-after.optimum="15pt"
                              text-align="center"
                              padding-top="3pt">
                        List of products need to be imported
                    </fo:block>
                    <fo:block font-size="18pt"
                              font-family="Arial"
                              line-height="24pt"
                              space-after.optimum="15pt"
                              background-color="blue"
                              color="white"
                              text-align="center"
                              padding-top="3pt">
                    </fo:block>
                    <fo:block font-size="12pt"
                              font-family="Arial"
                              text-align="right">
                        Date:
                        <xsl:value-of select="substring-before(date:date-time(),'T')"/>
                    </fo:block>
                    <fo:block font-size="12pt"
                              font-family="Arial"
                              space-after.optimum="15pt"
                              text-align="right"
                              >
                        Time:
                        <xsl:value-of select="substring-before(substring-after(date:date-time(),'T'),'+')"/>
                    </fo:block>
                    <fo:table border-collapse="separate" table-layout="fixed">
                        <fo:table-column column-width="1cm"/>
                        <fo:table-column column-width="6cm"/>
                        <fo:table-column column-width="2cm"/>
                        <fo:table-column column-width="3cm"/>
                        <fo:table-column column-width="4cm"/>

                        <fo:table-body>
                            <fo:table-row>
                                <fo:table-cell border-width="0.5pt" height="20pt" border-color="blue" border-style="solid" padding-top="10pt">
                                    <fo:block font-family="Arial" text-align="center">
                                            Product ID
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell border-width="0.5pt" border-color="blue" border-style="solid" padding-top="10pt">
                                    <fo:block font-family="Arial" text-align="center">
                                            Product Name
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell border-color="blue" border-width="0.5pt" border-style="solid" padding-top="10pt">
                                    <fo:block font-family="Arial" text-align="center">
                                            Price
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell border-color="blue" border-width="0.5pt" border-style="solid" padding-top="10pt">
                                    <fo:block font-family="Arial" text-align="center">
                                            Description
                                    </fo:block>
                                </fo:table-cell>

                            </fo:table-row>
                            <xsl:for-each select="products/product[quantityInStock &lt;=5]">
                                <fo:table-row>
                                    <fo:table-cell border-color="blue" border-width="0.5pt" border-style="solid">
                                        <fo:block font-family="Arial" text-align="center">
                                            <xsl:value-of select="productID"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-color="blue" border-width="0.5pt" border-style="solid"  width="200pt">
                                        <fo:block font-family="Arial" text-align="center">
                                            <xsl:value-of select="productName"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-color="blue" border-width="0.5pt" border-style="solid">
                                        <fo:block font-family="Arial" text-align="center">
                                            <xsl:value-of select="price"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-color="blue" border-width="0.5pt" border-style="solid">
                                        <fo:block font-family="Arial" text-align="center">
                                            <xsl:value-of select="decription"/>
                                        </fo:block>
                                    </fo:table-cell>

                                </fo:table-row>
                            </xsl:for-each>
                        </fo:table-body>
                    </fo:table>
                </fo:flow>
            </fo:page-sequence>
        </fo:root>
    </xsl:template>
</xsl:stylesheet>-->